Rsd.define('Rsd.control.MenuList', {
    extend: 'Rsd.control.List',
    xtype: 'menu-list',
    requires: ['Rsd.data.Menu',
        'Rsd.control.Svg',
        'Rsd.form.Link',
        'Rsd.form.ComboBox',
        'Rsd.form.Button'],
    margin: '0 0 0 0',
    width: 120,
    itemClick:'menuclick',
    cls: 'x-menu-list',
    /**
     * 被选中时样式
     */
    itemSelectedCls:'x-selected',
    usingItemHover:true,
    /**
     * label文字宽度
     */
     itemLabelWidth:50,
     /**
      * li 子节点宽度
      */
     innerItemWidth:null,
     /**
      * li 子节点高度
      */
     innerItemHeight:null,
     /**
      * 菜单布局方向：vbox or hbox
      */
     layout:'hbox',
     //禁止换行
     wrap:false,
    //菜单根节点,菜单子元素 item 支持 flex 属性，设置后会被应用到li 节点上
    //menu:null,
    //logo 图片
    //logo
    /**
     *
     * */
    constructor: function MenuList(config) {
 
        this.apply(config);

        if(this.logo)
        {
            this.label.content = this.logo;
            this.label.visible = false;
        }
        var _layout = this.layout;
        if(_layout == 'vbox')
        {
            this.itemStyle={"height":'50px',"width":'100%',"lineHeight": '30px'};
        }
        if(_layout == 'hbox')
        {
            this.itemStyle={"display":"inline-block", "lineHeight": '30px'}; 
        }
    },
  
    /*
    *
    * */
    loadData:function loadData(menu,callback)
    {
        var me = this;
        var _menu = menu||me.menu;
        if(Rsd.isArray(_menu))
        {
            _menu = Rsd.create('Rsd.data.Menu',{children:_menu});
        }
        if(_menu)
        {
            if(!(_menu instanceof Rsd.data.Menu)) {
                console.error(_menu);
                throw new Error('argumeng data is not Rsd.data.Menu object when it call Rsd.control.MenuList loadData.');
            }

            me.menu = _menu;
            var _nodeList=[];
            var _list = _menu.children||[];
            for(var i in _list) {
                var m = _list[i]; 
                var _liStyle = m.liStyle|| m.itemStyle||{};
                if(m.width)
                {
                   _liStyle['width'] =  m.width;
                }
                if(m.height)
                {
                   _liStyle['height'] =  m.height;
                }
                _nodeList.push({
                    xtype: 'svg',
                    //margin: '10 5 10 15',
                    id:m.id,
                    label: {
                        position: 'right',
                        space:0,
                        width:m.labelWidth||me.itemLabelWidth||65,  
                        height:'unset',
                        align:'left',
                        content: m.text,  
                        visible:!Rsd.isEmpty(m.text),
                        cls:(m.children&&m.children.length > 0)?'x-menu-items':'x-menu-item'
                    },
                    ctrlStyle:{height:null},
                    width: me.innerItemWidth || '100%',// 内部控件宽度,
                    height: me.innerItemHeight || 'auto',// 内部控件高度,
                    flex:m.flex,
                    click:m.click||null,
                    dblClick:m.dblClick||null,
                    usingHover:m.hover!==false,
                    liStyle:_liStyle,//兼容旧版本itemStyle
                    dsTagName: m.icon,
                    tip:m.tip||'', 
                    menu: m,
                });
            }

            me.callParent(_nodeList,callback);
        }

        return this;
    }, 
    /*
    *
    * */
    menuclick:function menuclick() {
        alert('未设置ListMenu.itemClick属性。')
    }


},function(type) {

    var _menuGetter = function () {
        return this.__menu;

    };

    var _menuSetter = function (value) {

        this.__menu = value;
    };


    this.defineProperty(type, "menu", _menuGetter, _menuSetter, true);
});
